# -*- coding: utf-8 -*-
__author__ = 'xuliliang'
# @Time    : 2018/8/8 上午11:25
# @Author  : 'xuliliang'
# @Email   : xuliliang@u51.com
# @File    : serializers.py
# @Software: PyCharm
#序列化的作用是让模型中的各字段可以以json形式展现出来。也就是在这里定义接口返回的字段信息

from .models import  Product
from rest_framework import serializers
from django.contrib.auth.models import User, Group
class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ('url', 'username', 'email', 'groups')


class GroupSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Group
        fields = ('url', 'name')

class ProductSerializer(serializers.ModelSerializer):
    class Meta:
        model = Product
        fields = ('id', 'created', 'name', 'describe', 'price', 'isDelete')

class SnippetSerializer(serializers.Serializer):
    pass

# class ResetApiSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:
#         model = reset_api
#         fields = "__all__"


